<?php


function getMarkersInZone($lat, $long, $db) {
	$sql = "SELECT * FROM data";// where product_score IS  NULL";
	$result = $db->query($sql);
	$retValues = array();
	while ($db->next_record()) {
		array_push($retValues, $db->f("lat"));
		array_push($retValues, $db->f("lng"));
	}
	return $retValues;
}

function getMarkerDetails($lat, $long, $db) {
	$sql = "SELECT * FROM data where lat LIKE ".$lat." and lng LIKE ".$long;
	$result = $db->query($sql);
	$retValues = array();
	while ($db->next_record()) {
		array_push($retValues, $db->f("lat"));
		array_push($retValues, $db->f("lng"));
		array_push($retValues, $db->f("message"));
		array_push($retValues, $db->f("userCount"));
		array_push($retValues, $db->f("dangerLevel"));
	}
	return $retValues;

}

function createMarker($lat, $long, $comment, $rating, $db) {
	$sql = "insert into data values(".$lat.",".$long.",\"".$comment."\",1,".$rating.");"	;
	$result = $db->query($sql);
}

function updateMarker($lat, $long, $db) {
	$sql = "update data set userCount = userCount + 1 where lat = ".$lat." and lng = ".$long;
	$result = $db->query($sql);
}


?>
